@echo off
chcp 65001
echo ========================================
echo  Spring Boot 3 OAuth2 + JWT SSO 系统
echo ========================================
echo.

echo 正在编译项目...
call mvn clean install -DskipTests
if %errorlevel% neq 0 (
    echo 编译失败！
    pause
    exit /b 1
)

echo.
echo 编译完成！准备启动服务...
echo.

echo 1. 启动 OAuth2 授权服务器 (端口: 9000)...
start "OAuth2 授权服务器" cmd /k "cd oauth2-authorization-server && mvn spring-boot:run"

echo 等待授权服务器启动完成（约30秒）...
timeout /t 30 /nobreak > nul

echo 2. 启动 OA 系统 (端口: 8080)...
start "OA 系统" cmd /k "cd oa-system && mvn spring-boot:run"

echo 等待 OA 系统启动...
timeout /t 15 /nobreak > nul

echo 3. 启动风控系统 (端口: 8081)...
start "风控系统" cmd /k "cd risk-control-system && mvn spring-boot:run"

echo 等待风控系统启动...
timeout /t 15 /nobreak > nul

echo 4. 启动门户系统 (端口: 8083)...
start "门户系统" cmd /k "cd portal-system && mvn spring-boot:run"

echo.
echo ========================================
echo  所有服务启动完成！
echo ========================================
echo.
echo 访问地址：
echo  - OAuth2 授权服务器: http://www.oauth2server.com:9000
echo  - OA 系统:          http://www.oauth2server.com:8080
echo  - 风控系统:         http://www.oauth2server.com:8081
echo  - 门户系统:         http://www.oauth2server.com:8083/portal
echo.
echo 测试账号：
echo  - 管理员:    admin / 123456
echo  - OA用户:    oa_user / 123456
echo  - 风控专员:  risk_user / 123456
echo  - 普通用户:  user / 123456
echo.
echo 请等待所有服务完全启动后再进行测试...
echo ========================================

pause